/**
 * 
 */
package net.kaixinpig.processor;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import container.AbstractProcessor;
import container.TemplateHelper;
import freemarker.template.TemplateException;

import logging.Level;
import logging.Logger;
import servlet.annotation.Parameter;
import servlet.annotation.RequestProcessor;
import servlet.annotation.RequestProcessing;

/**
 * @author think
 *
 */
@RequestProcessor
public class HelloProcessor extends  AbstractProcessor{
	private static final Logger LOGGER = Logger.getLogger(HelloProcessor.class.getName());
	
	@RequestProcessing(value={"/index.htm","/index"})
	public void index(@Parameter(name="userName",defaultValue="zhangsan") String name,
			@Parameter(name="msg",defaultValue="hello") String msg ){
		
		LOGGER.info("hello");
		Map dataModel = new HashMap();
		dataModel.put("userName", name);
		dataModel.put("msg", msg);
		/*try {
			this.getResponse().getWriter().write(name+" says "+msg);
		} catch (IOException e) {
			LOGGER.log(Level.WARN, "index error", e);
		}*/
		try {
			TemplateHelper.getInstance().render("test.ftl", dataModel , this.getResponse().getWriter());
		} catch (Exception e) {
			LOGGER.log(Level.WARN, "index error", e);
		}
	}
	

}
